package com.jinbooks.persistence.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jinbooks.entity.merchant.MerchantProduct;
import com.jinbooks.entity.merchant.dto.MerchantProductPageDto;
import com.jinbooks.persistence.mapper.MerchantProductMapper;
import com.jinbooks.persistence.service.MerchantProductService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 商户产品Service实现类
 *
 * @author lingma
 */
@Service
@RequiredArgsConstructor
public class MerchantProductServiceImpl implements MerchantProductService {

    private final MerchantProductMapper baseMapper;

    @Override
    public Page<MerchantProduct> pageList(MerchantProductPageDto dto) {
        return baseMapper.pageList(dto.build(), dto);
    }

    @Override
    public MerchantProduct getById(String id) {
        return baseMapper.selectById(id);
    }

    @Override
    public boolean save(MerchantProduct merchantProduct) {
        return baseMapper.insert(merchantProduct) > 0;
    }

    @Override
    public boolean update(MerchantProduct merchantProduct) {
        return baseMapper.updateById(merchantProduct) > 0;
    }

    @Override
    public boolean deleteById(String id) {
        return baseMapper.deleteById(id) > 0;
    }

    @Override
    public boolean deleteByIds(List<String> ids) {
        return baseMapper.deleteByIds(ids) > 0;
    }
}